package com.poc.mxbeans.impl;

import java.util.ArrayList;
import java.util.List;

import com.poc.EmployeeInfo;
import com.poc.mxbeans.EmployeeDataMXBean;

public class EmployeeData implements EmployeeDataMXBean {

	private static List<EmployeeInfo> empInfos = new ArrayList<EmployeeInfo>();

	static {
		populateEmpInfo();
	}

	public EmployeeInfo[] getEmployeeInfos() {
		return empInfos.toArray(new EmployeeInfo[5]);
	}

	public int getSize() {
		return empInfos.size();
	}

	public synchronized void clear() {
		empInfos.clear();
	}

	public synchronized void populate() {
		populateEmpInfo();
	}

	private static void populateEmpInfo() {
		empInfos.add(new EmployeeInfo("Amit", 30));
		empInfos.add(new EmployeeInfo("Anil", 33));
		empInfos.add(new EmployeeInfo("Kapil", 40));
		empInfos.add(new EmployeeInfo("Arun", 36));
		empInfos.add(new EmployeeInfo("Praveen", 20));
	}

}
